/* 
vuex的模块话:其实本质上是一个包含state mutations actions getters 属性的对象  
把这个对象暴露给vuex的new Vuex.Store()中进行模块化配置
*/
import axios from "axios";

const state = {
  movieList: [],
};
const mutations = {
  setMovieList(state, payload) {
    state.movieList = payload.movieList;
  },
};
const actions = {
  async getMovieList({ commit }) {
    const result = await axios.get(
      `https://pcw-api.iqiyi.com/search/recommend/list?channel_id=1&data_type=1&mode=11&page_id=2&ret_num=48&session=b9fd987164f6aa47fad266f57dffaa6a`
    );
    // console.log(result);
    commit("setMovieList", { movieList: result.data.data.list });
  },
};
const getters = {};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
